<?php
require_once 'Vega/Module/Action.php';
require_once APP_PATH.DS.'includes/BbData.php';

class SaveAction extends Vega_Module_Action
{
    public function execute()
    {
		$this->setOption('output', FALSE);
		
		$userId = isset($_REQUEST['user_id'])?$_REQUEST['user_id']:null;
		$userName = isset($_REQUEST['user_name'])?$_REQUEST['user_name']:null;
		$data = isset($_REQUEST['data'])?$_REQUEST['data']:null;
		
		if ($userId != null && $userName != null && $data != null) {
			
			$bbData = new BbData();
			$result = $bbData->save($userId, $userName, $data);
			
			if ($result == true) 
				header('location: /data?success=1');
			else
				header('location: /data?error=1');
			
		}
		else {
			header('location: /data?error=1');
		}
		
		die;
    }
	

 
}